import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Layout from '@/views/layout/Layout'

export const constantRouterMap = [{
    path: '/login',
    component: () =>
        import('@/views/login/index'),
    hidden: true
},
{
    path: '/404',
    component: () =>
        import('@/views/sys/errorPage/404'),
    hidden: true
},
{
    path: '/401',
    component: () =>
        import('@/views/sys/errorPage/401'),
    hidden: true
},
{
    path: '',
    component: Layout,
    redirect: '/newApplication/index',
    children: [{
        path: 'home',
        component: () =>
            import('@/views/home/index'),
        name: 'home',
        meta: {
            title: '首页',
            icon: 'home',
            noCache: true
        }
    }]
},
]

export default new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({
        y: 0
    }),
    routes: constantRouterMap
})

export const asyncRouterMap = [

    /////////////////////用户/////////////////////
    {
        path: '/user',
        component: Layout,
        redirect: '/user/index',
        children: [
            {
                path: 'index',
                component: () =>
                    import('@/views/sys/user/index'),
                name: 'user',
                meta: {
                    title: '用户列表',
                    icon: 'icon',
                    noCache: true,
                    roleName: "USER_MANAGER"
                }
            },
        ]
    },

    /////////////////////角色/////////////////////
    {
        path: '/role',
        component: Layout,
        redirect: '/role/index',
        children: [
            {
                path: 'index',
                component: () =>
                    import('@/views/sys/role/index'),
                name: 'role',
                meta: {
                    title: '角色列表',
                    icon: 'icon',
                    noCache: true,
                    roleName: "ROLE_MANAGER"
                }
            },
        ]
    },

    /////////////////////数据字典/////////////////////
    {
        path: '/dataDictionary',
        component: Layout,
        redirect: '/dataDictionary/index',
        children: [
            {
                path: 'index',
                component: () =>
                    import('@/views/sys/dataDictionary/index'),
                name: 'dataDictionary',
                meta: {
                    title: '数据字典',
                    icon: 'icon',
                    noCache: true,
                    roleName: "DATADICTIONARY_MANAGER"
                }
            },
        ]
    },

    /////////////////////权限/////////////////////
    {
        path: '/permission',
        component: Layout,
        redirect: '/permission/index',
        children: [
            {
                path: 'index',
                component: () =>
                    import('@/views/sys/permission/index'),
                name: 'permission',
                meta: {
                    title: '权限列表',
                    icon: 'icon',
                    noCache: true,
                    roleName: "PERMISSION_MANAGER"
                }
            },
        ]
    },

    /////////////////////菜单/////////////////////
    {
        path: '/menu',
        component: Layout,
        redirect: '/menu/index',
        children: [
            {
                path: 'index',
                component: () =>
                    import('@/views/sys/menu/index'),
                name: 'menu',
                meta: {
                    title: '菜单管理',
                    icon: 'icon',
                    noCache: true,
                    roleName: "MENU_MANAGER"
                }
            },
        ]
    },
    ////////////////发言管理/////////////////////
    {
        path: '/speak',
        component: Layout,
        redirect: '/queryContent/index',
        children: [
            {
                path: '/queryContent/index',
                component: () =>
                    import('@/views/project/speak/queryContent/index'),
                name: 'queryContent',
                meta: {
                    title: '查询所有内容',
                    icon: 'icon',
                    noCache: true,
                    roleName: "queryContent"
                }
            },
            {
                path: '/queryContent/userInfo',
                component: () =>
                    import('@/views/project/speak/userInfo/index'),
                name: 'userInfo',
                meta: {
                    title: '用户信息',
                    icon: 'icon',
                    noCache: true,
                    roleName: "userInfo"
                },
                hidden:true
            },
            {
                path: '/sensitiveWords/index',
                component: () =>
                    import('@/views/project/speak/sensitiveWords/index'),
                name: 'sensitiveWords',
                meta: {
                    title: '敏感词',
                    icon: 'icon',
                    noCache: true,
                    roleName: "sensitiveWords"
                },
                hidden:true
            },
            {
                path: '/sensitiveWords/ziDingYi',
                component: () =>
                    import('@/views/project/speak/sensitiveWords/ziDingYi'),
                name: 'sensitiveWords',
                meta: {
                    title: '敏感词自定义',
                    icon: 'icon',
                    noCache: true,
                    roleName: "sensitiveWords"
                },
                hidden:true
            }


        ]
    },
    ////////////////用户管理/////////////////////
    {
        path: '/user',
        component: Layout,
        redirect: '/newApplication/index',
        children: [
            {
                path: '/newApplication/index',
                component: () =>
                    import('@/views/project/user/newApplication/index'),
                name: 'newApplication',
                meta: {
                    title: '新申请',
                    icon: 'icon',
                    noCache: true,
                    roleName: "NewApplication"
                }
            },
            {
                path: '/userWarning/index',
                component: () =>
                    import('@/views/project/user/userWarning/index'),
                name: 'userWarning',
                meta: {
                    title: '用户预警',
                    icon: 'icon',
                    noCache: true,
                    roleName: "UserWarning"
                }
            },
            {
                path: '/appointUser/index',
                component: () =>
                    import('@/views/project/user/appointUser/index'),
                name: 'appointUser',
                meta: {
                    title: '委任用户',
                    icon: 'icon',
                    noCache: true,
                    roleName: "AppointUser"
                }
            }
        ]
    },

     /////////////////////日志/////////////////////
     {
        path: '/log',
        component: Layout,
        redirect: '/log/index',
        children: [
            {
                path: 'index',
                component: () =>
                    import('@/views/sys/log/index'),
                name: 'log',
                meta: {
                    title: '日志管理',
                    icon: 'icon',
                    noCache: true,
                    roleName: "LOG_MANAGER"
                }
            },
        ]
    },

    //////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////

    /////////////////////新闻公告/////////////////////
    {
        path: '/notice',
        component: Layout,
        redirect: '/notice/index',
        children: [{
            path: 'index',
            component: () =>
                import('@/views/project/notice/index'),
            name: 'notice',
            meta: {
                title: '新闻公告',
                icon: 'icon',
                noCache: true,
                roleName: "NOTICE"
            }
        },
        {
            path: 'detail',
            component: () =>
                import('@/views/project/notice/detail'),
            name: 'noticeDetail',
            meta: {
                title: '新闻公告详情',
                icon: 'icon',
                noCache: true,
                roleName: "NOTICE"
            }
        },
        {
            path: 'add',
            component: () =>
                import('@/views/project/notice/add'),
            name: 'noticeAdd',
            meta: {
                title: '新增新闻公告',
                icon: 'icon',
                noCache: true,
                roleName: "NOTICE"
            }
        },
        {
            path: 'edit',
            component: () =>
                import('@/views/project/notice/edit'),
            name: 'noticeEdit',
            meta: {
                title: '编辑新闻公告',
                icon: 'icon',
                noCache: true,
                roleName: "NOTICE"
            }
        }
        ]
    },

    {
        path: '*',
        redirect: '/404',
        hidden: true
    }
]
